package com.deer.remote.common.system;

import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;

import com.deer.remote.common.graphic.Screenshot;

/**
 * Created by matrixy on 2018/4/9.
 */
public final class LocalComputer {
	static Robot robot = null;

	/**
	 * 创建整屏截图
	 * 
	 * @return
	 */
	public static Screenshot captureScreen() {
		return new Screenshot(robot.createScreenCapture(getScreenSize()));
	}

	/**
	 * 获取屏幕分辨率
	 * 
	 * @return
	 */
	public static Rectangle getScreenSize() {
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		return new Rectangle((int) screenSize.getWidth(), (int) screenSize.getHeight());
	}

	public static void init() {
		try {
			robot = new Robot();
		} catch (AWTException ex) {
			throw new RuntimeException(ex);
		}
	}
}
